﻿<%@ Page Title="" Language="C#" MasterPageFile="~/InputCtrl.Master" AutoEventWireup="true" CodeBehind="CustomValidator.aspx.cs" Inherits="LiveDemo.InputCtrl.CustomValidator" %>
<%@ Register
    Assembly="AjaxControlToolkit"
    Namespace="AjaxControlToolkit"
    TagPrefix="AjaxToolkit" %>
<%@ Register assembly="System.Web.Silverlight" namespace="System.Web.UI.SilverlightControls" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        function onSourceDownloadProgressChanged(sender, eventArgs) {
            var value = 0;
            if (eventArgs.progress) {
                value = eventArgs.progress;
            }
            else {
                value = eventArgs.get_progress();
            }
            sender.get_element().content.findName("progressBar").Width = value * sender.get_element().content.findName("progressBarBackground").Width;
        }
    </script> 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="logo_SlInputCtrl"></div>
    <div class="heading">
        CustomValidator Demonstration
    </div>
    <div style="height:400px;width:540px">
        <asp:Silverlight ID="Silverlight1" 
                runat="server" 
                Source="~/ClientBin/CustomValidatorDemo.xap" MinimumVersion="2.0.31005.0" 
                Windowless="true"
                OnPluginSourceDownloadProgressChanged ="onSourceDownloadProgressChanged"
                SplashScreenSource="SplashValidators.xaml"
                InitParameters="Culture=en-US,UICulture=en-US"
                Height="100%" 
                Width="100%">
        </asp:Silverlight>
    </div>
    <asp:Panel ID="properties_HeaderPanel" runat="server" Style="cursor: pointer;">
        <div class="heading">
            <asp:ImageButton ID="Properties_ToggleImage" runat="server" ImageUrl="~/images/expand.jpg" AlternateText="expand"  />
            Custom Event
        </div>
    </asp:Panel>
    <asp:Panel ID="properties_ContentPanel" runat="server" Style="overflow: hidden;" Height="0px">
        <p>
            No have especific dependecy Property for <b>customvalidator</b>
        </p>
        <p>
            <span class="subheading">
            Event:&nbsp;
            </span>
            <b>CustomValidate</b>(object sender, DependencyPropertyChangedEventArgs e)
        </p>
        <p>
            <span class="subheading">
            How to get value to validation ?<br />
            </span>
            CustomValidator cusvld = (sender as CustomValidator);<br />
            string value = (cusvld.ElementValidator as <em><b>[Type of Control]</b></em>).<em><b>[Name property]</b></em>;<br />
        </p>
        <p>
            <span class="subheading">
            How to set result in event CustomValidate ?<br />
            </span>
            CustomValidator cusvld = (sender as CustomValidator);<br />
            cusvld.SetValue(CustomValidator.ExternalResultProperty,<em><b>[true or False]</em></b>);
        </p>
    </asp:Panel>

    <ajaxToolkit:CollapsiblePanelExtender ID="cpeProperties" runat="Server"
        TargetControlID="properties_ContentPanel"
        ExpandControlID="properties_HeaderPanel"
        CollapseControlID="properties_HeaderPanel"
        SuppressPostBack ="true"
        CollapsedImage ="~/Images/expand.jpg"
        ExpandedImage ="~/Images/collapse.jpg"
        Collapsed="True"
        ImageControlID="properties_ToggleImage" />
</asp:Content>
